import sys;


class ClassName(object):
    i = 12345

    def f(self):
        return 'hello world'


x = ClassName()

print(x.i)
print(x.f())


class Complex:
    def __init__(self, realpart, imagpart):
        self.r = realpart
        self.i = imagpart


x = Complex(3.0, -4.5)
print(x.r, x.i)


class Test:
    def pri(self):
        print(self)
        print(self.__class__)


t = Test()
t.pri()


class people:
    name = ''
    age = 0
    __weight = 0

    def __init__(self, n, a, w):
        self.name = n
        self.age = a
        self.__weight = w

    def speak(self):
        print("%s 说: 我 %d 岁。" % (self.name, self.age))


p = people('runoob', 10, 30)
p.speak()


class MyClass(object):
    myVersion = '1.1'

    def showMyVersion(self):
        print(MyClass.myVersion)


mc = MyClass()
print(mc.showMyVersion())
print('--------------------------------------')
print(MyClass.__dict__)

print('--------------------------------------')
print('--------------------------------------')
list = [1, 2, 3, 4]
it = iter(list)
print(next(it))
print(next(it))

print('--------------------------------------')
print('--------------------------------------')


def fibonacci(n):
    a, b, counter = 0, 1, 0

    while True:
        if counter > n:
            return
        yield a
        print(a)
        a, b = b, a + b
        counter += 1
        print(a)


f = fibonacci(10)
print('--------------------------------------')
print('--------------------------------------')


def test2(n):
    print("hello")
    for i in range(n):
        yield i * i
        print("===========i*i===========", i * i)


for i in test2(5):
    print('--------i--------', i)
    print('test')

print(MyClass.__class__)
print(MyClass.__name__)
print(MyClass.__bases__)

print('--------------------------------------')
print('--------------------------------------')


class P(object):
    def __del__(self):
        print("P del")


class C(P):
    def __init__(self):
        print('initialized')

    def __del__(self):
        P.__del__(self)
        print('deleted')


c1 = C()
print(c1)
c2 = c1
c3 = c1
print(id(c1), id(c2), id(c3))

del c1
del c2
del c3
